package com.hangzhou.welbeing.welbeinginstrument.activity;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.hangzhou.welbeing.welbeinginstrument.R;
import com.hangzhou.welbeing.welbeinginstrument.utils.Utils;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 时间 2017 年 09 月 22.
 * 作者 Administrator  刘传华
 * 公司 杭州惟君医疗科技有限公司
 * 包名 com.hangzhou.welbeing.pregnant.welbeing_pregnant.activity
 * 工程名 welbeing_pregnant
 */
public class MyStateActivity extends Activity {
    @Bind(R.id.activity_my_state_iv_return)
    ImageView activityMyStateIvReturn;
    @Bind(R.id.activity_my_state_rl_tv_I_prepare_pregnant)
    TextView activityMyStateRlTvIPreparePregnant;
    @Bind(R.id.activity_my_state_I_prepare_pregnant)
    RelativeLayout activityMyStateIPreparePregnant;
    @Bind(R.id.activity_my_state_tv_phase)
    TextView activityMyStateTvPhase;
    @Bind(R.id.activity_my_state_iv_upware_arrow_01)
    ImageView activityMyStateIvUpwareArrow01;
    @Bind(R.id.activity_my_state_iv_down_arrow)
    ImageView activityMyStateIvDownArrow;
    @Bind(R.id.activity_my_state_rl_tv_I_am_a_pregnant_mother)
    TextView activityMyStateRlTvIAmAPregnantMother;
    @Bind(R.id.activity_my_state_rl_I_am_a_pregnant_mother)
    RelativeLayout activityMyStateRlIAmAPregnantMother;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_state);
        ButterKnife.bind(this);

        Utils.setStatusBar(this,false,false);
        Utils.setStatusTextColor(false,this);

        SharedPreferences sp = getSharedPreferences("second_app_internal_data", 0);
        String user_select_state = sp.getString("user_select_state","");
        if(user_select_state.equals("1")){
            activityMyStateIPreparePregnant.setBackgroundResource(R.mipmap.choose_1);
            activityMyStateRlIAmAPregnantMother.setBackgroundResource(R.mipmap.tag_bt);
        }else if(user_select_state.equals("2")){
            activityMyStateIPreparePregnant.setBackgroundResource(R.mipmap.tag_bt);
            activityMyStateRlIAmAPregnantMother.setBackgroundResource(R.mipmap.choose_1);
        }

    }

    @OnClick({R.id.activity_my_state_iv_return, R.id.activity_my_state_I_prepare_pregnant, R.id.activity_my_state_rl_I_am_a_pregnant_mother})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.activity_my_state_iv_return:
                finish();
                break;
            case R.id.activity_my_state_I_prepare_pregnant: //怀孕中
                SharedPreferences sp = getSharedPreferences("second_app_internal_data", 0);
                SharedPreferences.Editor edit = sp.edit();
                edit.putString("user_select_state","1");
                edit.commit();

                activityMyStateIPreparePregnant.setBackgroundResource(R.mipmap.tag_bt);
                activityMyStateRlIAmAPregnantMother.setBackgroundResource(R.mipmap.choose_1);

                Intent intent = new Intent(MyStateActivity.this, SetDueDateActivity.class);
                startActivity(intent);
                finish();
                break;
            case R.id.activity_my_state_rl_I_am_a_pregnant_mother: //我在备孕
                SharedPreferences sp1 = getSharedPreferences("second_app_internal_data", 0);
                SharedPreferences.Editor edit1 = sp1.edit();
                edit1.putString("user_select_state","2");
                edit1.commit();
                activityMyStateIPreparePregnant.setBackgroundResource(R.mipmap.choose_1);
                activityMyStateRlIAmAPregnantMother.setBackgroundResource(R.mipmap.tag_bt);

                Intent intent5 = new Intent(MyStateActivity.this, PreparePregnantActivity.class);
                startActivity(intent5);
                finish();
                break;
        }
    }
}
